#第一周 第一次作业
#2019.12.31 mengli
'''
打印乘法口诀
while循环打印，方法1
'''
print('while循环打印，方法1')
i=1
while i<=9:
    j=1
    while j<=i:
        print('{}*{}={:<2}'.format(j,i,j*i),end=' ')
        j=j+1
    print('')
    i=i+1
print('-' * 100)
'''
打印乘法口诀
while循环打印，方法2
'''
print('while循环打印，方法2')
i=9
while i>=1:
    j=1
    while j<=i:
        print('{}*{}={:<2}'.format(j,i,j*i),end=' ')
        j=j+1
    print('')
    i=i-1
print('-' * 100)
'''
打印乘法口诀
while循环打印，方法3
'''
print('while循环打印，方法3')
i=1
while i<=9:
    j=9
    while j>=1:
        if j>i:
            print(' ' * 6, end=' ')
        else:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
        j=j-1
    print('')
    i=i+1
print('-' * 100)
'''
打印乘法口诀
while循环打印，方法4
'''
print('while循环打印，方法4')
i=9
while i>=1:
    j=9
    while j>=1:
        if j<=i:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
        else:
            print(' ' * 6, end=' ')
        j=j-1
    print('')
    i=i-1
print('-' * 100)
'''
打印乘法口诀
for in循环打印，方法1
'''
print('for in循环打印，方法1')
for i in (1,2,3,4,5,6,7,8,9):
    for j in (1,2,3,4,5,6,7,8,9):
        if j<=i:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
    print('')
print('-' * 100)
'''
打印乘法口诀
for in循环打印，方法2
'''
print('for in循环打印，方法2')
for i in (9,8,7,6,5,4,3,2,1):
    for j in (1,2,3,4,5,6,7,8,9):
        if j<=i:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
    print('')
print('-' * 100)
'''
打印乘法口诀
for in循环打印，方法3
'''
print('for in循环打印，方法3')
for i in (1,2,3,4,5,6,7,8,9):
    for j in (9,8,7,6,5,4,3,2,1):
        if j > i:
            print(' ' * 6, end=' ')
        else:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
    print('')
print('-' * 100)
'''
打印乘法口诀
for in循环打印，方法4
'''
print('for in循环打印，方法4')
for i in (9,8,7,6,5,4,3,2,1):
    for j in (9,8,7,6,5,4,3,2,1):
        if j <= i:
            print('{}*{}={:<2}'.format(j, i, j * i), end=' ')
        else:
            print(' ' * 6, end=' ')
    print('')
print('-' * 100)

